package com.com.twotestlist;



public class LikedList implements List {
    Node head=new Node();
    int size;
    @Override
    public int size() {
        return size;
    }

    @Override
    public Object get(int i) {
        Node p=head;
        for(int j=0;j<=i;j++){
            p=p.next;
        }
        return p.date;
    }

    @Override
    public boolean isEmpty() {
        return size==0;
    }

    @Override
    public boolean contains(Object e) {
        return false;
    }

    @Override
    public int indexOf(Object e) {
        return 0;
    }

    @Override
    public void add(int i, Object e) {
    Node p=head;
    for(int j=0;j<i;j++){
        p=p.next;
    }
    Node newNode=new Node(e);
    newNode.next=p.next;
    p.next=newNode;
    size++;
    }

    @Override
    public void add(Object e) {
   add(size,e);
    }

    @Override
    public boolean addBefore(Object obj, Object e) {
        return false;
    }

    @Override
    public boolean addAfter(Object obj, Object e) {
        return false;
    }

    @Override
    public Object remove(int i) {
        return null;
    }

    @Override
    public boolean remove(Object e) {
        return false;
    }

    @Override
    public Object replace(int i, Object e) {
        return null;
    }

    @Override
    public String toString() {
        Node p=head;
        StringBuilder str=new StringBuilder();
        str.append("[");
        for(int i=0;i<size;i++){
            p=p.next;
            if(i!=size-1) {
                str.append(p.date + ",");
            }else{
                str.append(p.date+"]");
            }

        }
        return str.toString();
    }
}
